﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.SheepConditionCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 品相测定
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepConditionController : ControllerBase
    {

        private readonly IMediator _mediator;
        private readonly ISheepConditionService sheepConditionService;



        public SheepConditionController(IMediator mediator, ISheepConditionService sheepConditionService)
        {
            _mediator = mediator;
            this.sheepConditionService = sheepConditionService;
        }

        /// <summary>
        /// 品相测定添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> CreateSheepCondition(SheepConditionCreateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        ///品相测定显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Results<PageOutput<SheepCondition>>> GetSheepCondition(SheepConditionListCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 品相测定删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelSheepCondition(SheepConditionDelCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        ///  品相测定反填
        /// </summary>
        /// <param name="SheepConditionId"></param>
        /// <returns></returns>

        [HttpGet]
        public async Task<Results<SheepCondition>> GetFtSheepCondition(int SheepConditionId)
        {
            return Results<SheepCondition>.DataResult(sheepConditionService.GetFtSheepCondition(SheepConditionId));
        }

        /// <summary>
        /// 品相测定测定
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Results<int>> Update(SheepConditionUpdaCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 批量删除品相测定
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelRangeSheepCondition(SheepConditionDelRangeCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
